home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
tools
/
czesc_2
/
mfilemode
/
source
/
loaders.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-09-05
|
4KB
|
159 lines
// Loaders.c - Copyright © 1994 Mike Austin
#include <string.h>
#include <exec/memory.h>
#include <dos/exall.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/gadtools.h>
#include <proto/multiuser.h>
#include <pragmas/nofrag_pragmas.h>
#include <proto/nofrag_protos.h>
#include "MFileMode.h"
#include "GUI.h"
VOID LoadVolumes(struct List *List)
{
static struct DosList *DosList;
static struct Node *Node;
static UWORD NumNodes = 0, Num;
GT_SetGadgetAttrs(MainGadgets[GD_GAD_FILE], MainWnd, NULL,
GTLV_Labels, ~0,
TAG_END);
GT_SetGadgetAttrs(MainGadgets[GD_GAD_FILE], MainWnd, NULL,
GTLV_Top, 0,
TAG_END);
FreeList(&FileList);
if(DosList = LockDosList(LDF_VOLUMES | LDF_ASSIGNS | LDF_READ))
{
while(DosList = NextDosEntry(DosList, LDF_VOLUMES | LDF_ASSIGNS | LDF_READ))
{
if(Node = AllocVecItem(MemChain, sizeof(struct Node) +
sizeof(UBYTE *) + strlen(BSTR2CSTR(DosList->dol_Name)) +
2, MEMF_CLEAR))
{
Node->ln_Name = (char *)(&(Node->ln_Name) + 1);
strcpy((char *)(&(Node->ln_Name) + 1), BSTR2CSTR(DosList->dol_Name));
strcat((char *)(&(Node->ln_Name) + 1), ":");
AddTail(&FileList, Node);
}
else
AlertUser(MainWnd, "Can't allocate memory", "");
NumNodes++;
}
UnLockDosList(LDF_VOLUMES | LDF_ASSIGNS | LDF_READ);
if(FileNames = AllocVecItem(MemChain, sizeof(UBYTE *) * NumNodes, 0L))
{
Node = FileList.lh_Head;
for(Num = 0; Num < NumNodes; Num++)
{
FileNames[Num] = Node->ln_Name;
Node = Node->ln_Succ;
}
}
else
AlertUser(MainWnd, "Can't allocate memroy", "");
}
else
AlertUser(MainWnd, "Can't lock dos list", "");
GT_SetGadgetAttrs(MainGadgets[GD_GAD_FILE], MainWnd, NULL,
GTLV_Labels, &FileList,
TAG_END);
GT_SetGadgetAttrs(MainGadgets[GD_GAD_PATH], MainWnd, NULL,
GTTX_Text, NULL,
TAG_END);
}
VOID LoadDirectory(BPTR Lock, struct List *List)
{
struct ExAllControl *EAControl;
struct ExAllData EAData[4];
struct ExAllData *Data;
struct Node *Node;
UWORD NumNodes = 0, Num;
BOOL More;
GT_SetGadgetAttrs(MainGadgets[GD_GAD_FILE], MainWnd, NULL,
GTLV_Labels, ~0,
TAG_END);
GT_SetGadgetAttrs(MainGadgets[GD_GAD_FILE], MainWnd, NULL,
GTLV_Top, 0,
TAG_END);
FreeList(&FileList);
if(EAControl = AllocDosObject(DOS_EXALLCONTROL, NULL))
{
EAControl->eac_LastKey = 0;
do
{
More = ExAll(Lock, EAData, sizeof(struct ExAllData) * 4,
ED_TYPE, EAControl);
if(EAControl->eac_Entries != 0)
{
Data = EAData;
do
{
if(Node = AllocVecItem(MemChain, sizeof(struct Node) +
sizeof(UBYTE *) + strlen(Data->ed_Name) + 2,
MEMF_CLEAR))
{
Node->ln_Name = (char *)(&(Node->ln_Name) + 1);
strcpy((char *)(&(Node->ln_Name) + 1), Data->ed_Name);
if(Data->ed_Type >= 0)
strcat((char *)(&(Node->ln_Name) + 1), "/");
AddTail(&FileList, Node);
}
else
AlertUser(MainWnd, "Can't allocate memory", "");
NumNodes++;
Data = Data->ed_Next;
}
while(Data);
}
else
More = FALSE;
}
while(More);
FreeDosObject(DOS_EXALLCONTROL, EAControl);
if(FileNames = AllocVecItem(MemChain, sizeof(UBYTE *) * NumNodes, 0L))
{
Node = FileList.lh_Head;
for(Num = 0; Num < NumNodes; Num++)
{
FileNames[Num] = Node->ln_Name;
Node = Node->ln_Succ;
}
}
else
AlertUser(MainWnd, "Can't allocate memory", "");
}
else
AlertUser(MainWnd, "Can't allocate dos object", "");
GT_SetGadgetAttrs(MainGadgets[GD_GAD_FILE], MainWnd, NULL,
GTLV_Labels, &FileList,
TAG_END);
}